package com.zhouixi.reproduce.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.zhouixi.reproduce.entity.User;
import com.zhouixi.reproduce.service.IUserService;

import cn.hutool.crypto.digest.DigestAlgorithm;
import cn.hutool.crypto.digest.Digester;

@RequestMapping("/user")
@ResponseBody
@Controller
public class UserController {

	@Autowired
	private IUserService userService;
	
	@RequestMapping("/add")
	public int add() {
		Digester md5 = new Digester(DigestAlgorithm.MD5);
		User user = new User();
		user = new User();
		user.setId("123");
		user.setPassword(md5.digestHex("123456"));
		user.setPhone("13266669999");
		user.setUserName("张三");
		return userService.add(user);
	}
	
	@RequestMapping("/find/{id}")
	public User findUser(@PathVariable int id ) {
		return userService.findUserById(id);
	}
}
